﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using BrightIdeasSoftware;
using GDFlacTool.Common;

namespace GDFlacTool
{
    public class TrackDragObject : List<Track>, IDragSource
    {
        public TrackDragObject() {}

        public TrackDragObject(bool refreshAfterDrop)
        {
            RefreshAfterDrop = refreshAfterDrop;
        }

        public bool RefreshAfterDrop { get; set; }


        object IDragSource.StartDrag(ObjectListView olv, MouseButtons button, OLVListItem item)
        {
            if (button != MouseButtons.Left)
                return null;

            if(olv.SelectedObjects.Count > 0)
            {
                Clear();

                foreach (var selectedObject in olv.SelectedObjects)
                {
                    Add((Track) selectedObject);
                }
            }

            return this;
        }

        DragDropEffects IDragSource.GetAllowedEffects(object dragObject)
        {
            if(dragObject is List<Track>)
            {
                return DragDropEffects.Copy | DragDropEffects.Move;
            }
                
            return DragDropEffects.None;
        }

        void IDragSource.EndDrag(object dragObject, DragDropEffects effect)
        {
            //Olv data = dragObject as List<Track>;

            //if(data == null)
            //    return;

            //if(RefreshAfterDrop)
            //{
            //    //data.
            //}
        }
    }
}
